//
//  AcitonBayStyleTitleView.m
//  WGFGlobalHouses
//
//  Created by welldone on 15/5/20.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "AcitonBayStyleTitleView.h"
#import "config.h"
#import "NSString+category.h"

@interface AcitonBayStyleTitleView()

@property (nonatomic,strong) NSLayoutConstraint* conLay;

@end

@implementation AcitonBayStyleTitleView

+(AcitonBayStyleTitleView *)creadView{
    
    AcitonBayStyleTitleView *view = [[[NSBundle mainBundle]loadNibNamed:@"AcitonBayStyleTitleView" owner:nil options:nil]lastObject];
    
    for (NSLayoutConstraint *conLayout in view.constraints) {
        
        if (conLayout.secondItem==view.aaddBtn && conLayout.secondAttribute  == NSLayoutAttributeTrailing) {
            view.conLay = conLayout;
            break;
        }
    }
    view.aeditBtn.hidden = YES;
    [view.atitleLab setFont:[UIFont fontWithName:@"TrebuchetMS-Bold" size:17]];
    
    
    CGRect buf = view.frame;
    buf.size.width = PMW;
    [view setFrame:buf];
    
    return  view;
}

- (IBAction)btnOnClick:(UIButton *)sender {
    
    if (sender.currentAttributedTitle > 0) {
        
        self.conLay.constant = 0;
        [sender setImage:[UIImage imageNamed:@"biaoji_icon"] forState:UIControlStateNormal];
        [sender setAttributedTitle:nil forState:UIControlStateNormal];
        self.aaddBtn.hidden = NO;

        
    }else{
      
        self.conLay.constant = -30;
        [sender setImage:nil forState:UIControlStateNormal];
        [sender setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [sender setAttributedTitle:[NSString makeLineStyle:@"完成" color:[UIColor whiteColor] fontSize:14.0] forState:UIControlStateNormal];
        self.aaddBtn.hidden = YES;
        
    }
    
}

@end
